package tech.aistar.mapper;

import org.apache.ibatis.annotations.*;
import tech.aistar.pojo.User;

@Mapper
public interface UserMapper {
    //查询（name）
    @Select("select * from user where username=#{value} ")
    User selectByUserName(String userName);
    //（电话）
    @Select("select * from user where phone=#{value} ")
    User selectByPhone(String phone);
    //（邮箱）
    @Select("select * from user where email=#{value} ")
    User selectByEmail(String email);
    //（添加）
    @Options(useGeneratedKeys = true, keyProperty = "userId")
    @Insert("insert into user(username,password,phone,email) values(#{username},#{password},#{phone},#{email})")
    int insert(User user);
    //(根据username删除)
    @Delete("delete from user where username=#{value}")
    int delete(String userName);
    //（修改密码）
    @Update("update user set password=#{password} where user_id=#{userId}")
    int updatePassword(User user);
    //（修改用户名）
    @Update("update user set username=#{username} where user_id=#{userId}")
    int updateUserName(User user);

}
